<template>
  <div>
    <el-table :data="payDetails" stripe border style="width: 100%;margin-top: 5px">
      <el-table-column prop="name" label="姓名" width="80" fixed></el-table-column>
      <el-table-column prop="gender" label="性别" width="70"></el-table-column>
      <el-table-column prop="birthday" label="出生日期" width="100"></el-table-column>
      <el-table-column prop="idCard" label="身份证" width="100"></el-table-column>
      <el-table-column prop="nativePlace" label="籍贯" width="90"></el-table-column>
      <el-table-column prop="phone" label="家庭号码" width="100"></el-table-column>
      <el-table-column prop="address" label="家庭住址" width="100"></el-table-column>
      <el-table-column prop="illness" label="病因" width="100"></el-table-column>
      <el-table-column prop="nation.name" label="民族" width="70"></el-table-column>
      <el-table-column prop="politicsStatus.name" label="政治面貌"></el-table-column>
      <el-table-column prop="roomPrice.name" label="病房类型"></el-table-column>
      <el-table-column prop="roomPrice.price" label="病房价格"></el-table-column>
      <el-table-column prop="medicinePrice.medicineName" label="药物名称"></el-table-column>
      <el-table-column prop="medicinePrice.price" label="药物价格"></el-table-column>
      <el-table-column prop="allDetails.allDetails" label="总计" width="70" fixed="right"></el-table-column>
      <el-table-column prop="isAccounts" label="是否结算" width="80">
        <template v-slot="scope">
          <el-tag v-if="scope.row.isAccounts" type="success">已结算</el-tag>
          <el-tag v-else type="danger">未结算</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="80" fixed="right">
        <template v-slot="scope">
          <el-button
              size="mini"
              type="primary"
              @click="showEditView(scope.$index, scope.row)"
          >编辑
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div>
      <el-dialog title="结算信息" :visible.sync="dialogVisible" width="30%">
        <table>
          <tr>
            <td>
              <el-tag>是否结算</el-tag>
            </td>
            <td>
              <el-switch
                  style="margin-left:6px"
                  v-model="payInfo.isAccounts"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  active-text="已结算"
                  inactive-text="未结算"
              >
              </el-switch>
            </td>
          </tr>
        </table>
        <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="doUpdatePayInfo"
        >确 定
        </el-button>
      </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  name: 'StaAll',
  data() {
    return {
      payDetails: [],
      payInfo:{
        isAccounts:false
      },
      dialogVisible:false,
    }
  },
  methods: {
    initPayDetails() {
      this.getRequest('/patient/payDetails/', this.payDetails).then((resp) => {
        if (resp) {
          this.payDetails = resp;
        }
      })
    },
    showEditView(index, data) {
      Object.assign(this.payInfo, data)
      this.dialogVisible = true
    },
    doUpdatePayInfo(){
      this.putRequest('/patient/PayInfo/', this.payInfo).then((resp) => {
        if (resp) {
          this.initPayDetails()
          this.dialogVisible = false
        }
      })
    }
  },

  mounted() {
    this.initPayDetails();
  }
}
</script>

<style>

</style>